package thn.glf.org.lib;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
public class MessageBox {
	public static enum button{OK, YES, NO, CANCLE, OKCANCLE,YESNO};
	public static void Show(Context context,String sms,DialogButton dialogButton){
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		
		switch (dialogButton) {
		case OK:		
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("OK", OK_Click);
			break;
		case CANCLE:
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("CANCLE", CANCLE_Click);
			break;
		case YES:
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("YES", YES_Click);
			break;
		case NO:
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("NO", NO_Click);
			
			break;
		case OKCANCLE:
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("OK", OK_Click)
			.setNegativeButton("CANCLE", CANCLE_Click);
			break;
		case YESNO:
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("YES", YES_Click)
			.setNegativeButton("NO", NO_Click);
			break;
		}
		AlertDialog alert = builder.create();
		alert.show();
	}
	private static OnClickListener OK_Click=new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface dialog, int which) {
			// TODO Auto-generated method stub			
			dialog.cancel();
		}
	};
	private static OnClickListener CANCLE_Click=new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface dialog, int which) {
			// TODO Auto-generated method stub
			dialog.cancel();
		}
	};
	private static OnClickListener YES_Click=new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface dialog, int which) {
			// TODO Auto-generated method stub
			dialog.cancel();
		}
	};
	private static OnClickListener NO_Click=new OnClickListener() {
		
		@Override
		public void onClick(DialogInterface dialog, int which) {
			// TODO Auto-generated method stub
			dialog.cancel();
		}
	};
	public static void Show(Context context,String sms,DialogButton dialogButton,OnClickListener[] onClickListener){
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		
		switch (dialogButton) {
		case OK:		
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("OK", onClickListener[0]);
			break;
		case CANCLE:
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("CANCLE", onClickListener[0]);
			break;
		case YES:
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("YES", onClickListener[0]);
			break;
		case NO:
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("NO", onClickListener[0]);
			
			break;
		case OKCANCLE:
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("OK", onClickListener[0])
			.setNegativeButton("CANCLE", onClickListener[1]);
			break;
		case YESNO:
			builder.setMessage(sms)
			.setCancelable(false)
			.setPositiveButton("YES", onClickListener[0])
			.setNegativeButton("NO", onClickListener[1]);
			break;
		}
		AlertDialog alert = builder.create();
		alert.show();
	}
}
